//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class RelativeOffsetEffect : Effect
    {
        private double tx;

        private double ty;

        public double XOffset
        {
            get { return tx; }
            set { tx = value; }
        }

        public double YOffset
        {
            get { return ty; }
            set { ty = value; }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("relOff"))
            {
                XOffset = SerializationHelper.GetOptionalPercent(c, "tx", 0);
                YOffset = SerializationHelper.GetOptionalPercent(c, "ty", 0);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("relOff"))
            {
                SerializationHelper.SetOptionalPercent(c, "tx", XOffset, 0);
                SerializationHelper.SetOptionalPercent(c, "ty", YOffset, 0);
            }
        }
    }
}